/*
 * Rho.h
 *
 *  Created on: May 24, 2011
 *      Author: marchi
 */

#ifndef RHO_H_
#define RHO_H_

#include "Array.h"
#include <iostream>
#include "typedefs.h"
#include "Charges.h"
#include "Metric.h"
using namespace Array;
#define VERTEX 8


class Rho : public array3<double> {
protected:
	Metric Mt;
	real qq[VERTEX];
	static const rvec cube[VERTEX];
	real TriDiff(real g, real cubi){return((g-cubi>=0.0)? cubi-g+1 : g-cubi+1);};
	void TriLinear(real, real, real, real);
public:
	Rho(){};
	Rho(unsigned int nx0,unsigned int ny0,unsigned int nz0):array3<double>(nx0,ny0,nz0){};
	Rho & operator=(double);
	void Density(Charges & );
	Metric & getMt(){return Mt;};
	double Sum(){
		double tot=0.0;
		for(unsigned int i=0;i<this->Size();i++) tot+=this->v[i];
		return tot;
	};
	friend Rho operator-(Rho &, Rho &);
	friend Rho operator+(Rho &, Rho &);
};

#endif /* RHO_H_ */
